package com.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

@Service
public class MailService {


    @Autowired
    private JavaMailSenderImpl mailSender;
    @Value("${spring.mail.username}")
    private String from;

    public void sendSimpleEmail(String to, String subject, String text){
        SimpleMailMessage message=new SimpleMailMessage();
        //纯文本邮件;
        message.setFrom(from);//发送人
        message.setTo(to);//发给谁
        message.setSubject(subject);//主题
        message.setText(text);//内容
        mailSender.send(message);
    }

}
